<%@ page language="java" contentType="text/html; charset=UTF-8"%>


<!---------------------------------------头部模块复用------------------------------------------>
<%@ include file="/res/FrontPage/PartialPageReferences/head.jsp" %>

<title>存款取款</title>

<script type="text/javascript">

function validate_required(field,alerttxt)
{
with (field)
  {
  var money = <%=((Users)session.getAttribute("users")).getYue() %>;
  var cash = <%=((Users)session.getAttribute("users")).getMoney() %>;
  var str = document.getElementById("cunkuanshuliang");
  var cunkuannum = str.value;
  if ( (cunkuannum-cash) >0)
    {alert(alerttxt);return false}
  else {return true}
  }
}

function validate_form(thisform)
{
with (thisform)
  {
  if (validate_required(cunkuan,"你的现金不够!\n\n提示：可以点击快速赚钱来增加现金。")==false)
    {cunkuan.focus();return false}
  }
}
</script>

<!-- -----------------------------------正文开始--------------------------------------- -->
<% if(session.getAttribute("users") == null){ %>
<script type="text/javascript">
	alert("请先登录哦~~~");
	window.location="/Bank/WebPage/FrontPage/index.jsp";
</script>
<%}else{ %>
<section class="contact_page">
    <div class="container">
        <div class="row">
            <div class="col-sm-6 col-sm-offset-3 m-t-50">
                <h2 class="underline heading">基于网络的安全存取款服务</h2>
                <p class="text-center">安全一直是大家关注的事情，不过我们的银行是可以保证大家资金的安全的，即使发生了存款丢失的事件，我们也会全额赔偿。</p>
            </div>
        </div>

        <div class="row">
        	
        	<!-- -------------------------------------------------------存取款功能开始------------------------------------------ -->
			<div class="col-xs-12 col-sm-6 section-top-30 wow fadeInRight" data-wow-duration="1s" data-wow-delay="0.2s">

                <div class="row contact_border">

                    <div class="contact_form">

                        <form class="form" action="/Bank/cunkuanqvkuan.do" onsubmit="return validate_form(this)" method="post">
                            <div class="col-xs-12"><h4 class="heading_left">账号余额：<%=((Users)session.getAttribute("users")).getYue()%>
                            </h4></div>
                            <div class="col-xs-12"><h4 class="heading_left">账号现金：<%=((Users)session.getAttribute("users")).getMoney()%>
                            </h4></div>
                            <div class="form-group col-xs-12 section-top-10">
                                <input id="cunkuanshuliang" type="text" class="form-control" name="cunkuan" placeholder="请输入存款数量" required>
                            </div>
                            <div class="clearfix visible-sm-block visible-md-block visible-xs-block"></div>
                            <div class="col-md-12 text-center section-bottom-15">
                                <button type="submit" class="btn btn-success">存款</button>
                            </div>
                            <input type="hidden" name="type" value="f1" />
                        </form>
                        
                        <form class="form" action="/Bank/cunkuanqvkuan.do" method="post">
                            <div class="form-group col-xs-12 section-top-10">
                                <input type="text" class="form-control" name="qvkuan" placeholder="请输入取款数量" required>
                            </div>
                            <div class="clearfix visible-sm-block visible-md-block visible-xs-block"></div>
                            <div class="col-md-12 text-center section-bottom-15">
                                <button type="submit" class="btn btn-success">取款</button>
                            </div>
                            <input type="hidden" name="type" value="f2" />
                        </form>
                        
                    </div>
                </div>
                
                <div class="row contact_border">

                    <div class="contact_form">

                        <form class="form" action="/Bank/qvkuan.do" method="post">
                            <div class="col-md-12 text-center section-bottom-15">
                                <button type="submit" class="btn btn-success">快速赚钱 +100</button>
                            </div>
                            <input type="hidden" name="type" value="f1" />
                        </form>
                        
                        <form class="form" action="/Bank/qvkuan.do" method="post">
                            <div class="col-md-12 text-center section-bottom-15">
                                <button type="submit" class="btn btn-success">快速花钱 -200</button>
                            </div>
                            <input type="hidden" name="type" value="f2" />
                        </form>
                        
                    </div>
                </div>
            </div>
            <!-- -------------------------------------------------------存取款功能结束------------------------------------------ -->
            
            
            <!-- -------------------------------------------------------近期存取记录开始------------------------------------------ -->
            <div class="col-xs-12 col-sm-6 section-top-30 wow fadeInRight" data-wow-duration="1s" data-wow-delay="0.2s">
                <div class="row contact_border">
                    <div class="contact_form">
                        <div class="form">
                        	<div class="col-xs-12"><h4 class="heading_left">这里仅显示近7天的记录</h4></div>
                            <div class="clearfix visible-sm-block visible-md-block visible-xs-block"></div>
                            <table border=’1’ cellspacing=’0’ cellpadding=’5’ class="table table-striped table-bordered table-hover table-condensed">
								<tr><th align="center"> 存取款ID </th><th align="center"> 类型(存款/取款) </th><th align="center"> 操作金额 </th><th align="center"> 操作时间(年-月-日 时:分:秒) </th><th align="center"> 账户余额 </th></tr>
								<%
									DAO dao = new DAO();
									String sqlyujv = "select * from cunkuanqvkuan where name = '" + ((Users)session.getAttribute("users")).getZhanghao() + "'";
									ArrayList<CunQvKuan> list = new ArrayList<CunQvKuan>();
									CunQvKuan cunqv = new CunQvKuan();
									list = dao.chaxuncunqv(sqlyujv);
									Collections.reverse(list);
									int i = 0;
								%>
								<% for(CunQvKuan cq : list){ %>
								<% i++; %>
								<tr><td align="center" valign="center"><%= cq.getId() %></td><td align="center" valign="center"><%= cq.getStyle() %></td><td align="center" valign="center"><%= cq.getMoney() %></td><td align="center" valign="center"><%= cq.getDate() %></td><td align="center" valign="center"><%= cq.getYue()+"" %></td></tr>
								<% //if(i>=10) break; %>
								<% } %>
							</table>
							<div class="col-xs-12"><h4 class="heading_left"> </h4></div>
							<div class="clearfix visible-sm-block visible-md-block visible-xs-block"></div>
                            <div class="col-md-12 text-center section-bottom-15">
                                <button type="button" class="btn btn-success" onClick="javascript:chaxun()">点击查询更多信息</button>
                                <script type="text/javascript">
                                	function chaxun(){
										window.location="DepositAndWithdrawalQueries.jsp";
									}
                                </script>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
            <!-- -------------------------------------------------------近期存取记录结束------------------------------------------ -->
        </div>
        <div class="row section-top-25">
            <div class="col-xs-12">
                <div class="map"></div>
            </div>
        </div>
    </div>
</section>
<%} %>
<!-- -----------------------------------正文结束--------------------------------------- -->

<!------------尾部顶端的两个角------------>
<div class="shape section-top-50"></div>
<!-----------------------------尾部页面复用------------------------------------->

<%@ include file="/res/FrontPage/PartialPageReferences/foot.jsp" %>